using System;
using System.Diagnostics;
using System.Net;

using octalforty.Chinchillin.Shared.Deployment;
using octalforty.Chinchillin.Shared.Deployment.Agent;
using octalforty.Chinchillin.Shared.Tracing;

namespace octalforty.Chinchillin.Agent.Core.Tracing.Impl
{
    public class TracingManagerService : ITracingManagerService
    {
        public IDeploymentCallback DeploymentCallback
        { get; set; }

        public void TraceEvent(IActionExecutionContext actionExecutionContext, TraceEventType eventType, int eventCode, string eventMessage)
        {
            if((int)actionExecutionContext.EventTypeFilter < (int)eventType)
                return;

            Console.WriteLine("[{0}] - {1} - {2} ({3}): {4}", Dns.GetHostName(), DateTime.Now, eventType, eventCode, eventMessage);

            DeploymentCallback.TraceEvent(Dns.GetHostName(), DateTime.Now, eventType, eventCode, eventMessage);
        }
    }
}